import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

let routesMb = [
    {path: '/', name: 'home',   meta:{mateAdmin:10},component: () => import('../views/home/index.vue')},
    {path: '/teacher', name: 'teacher',   meta:{mateAdmin:12},component: () => import('../views/teacher/lesson.vue')},
    {path: '/lesson', name: 'lesson',   meta:{mateAdmin:12},component: () => import('../views/teacher/index.vue')},
    {path: '/attention', name: 'attention',   meta:{mateAdmin:13},component: () => import('../views/attention/index.vue')},
    {path: '/login', name: 'login', component: () => import('../views/login/index.vue')},
    {path: '*', redirect: '/login'},
]

let routesPc=[
    {
        path: '/',
        name: 'home',
        component: () => import( '../page/home/index.vue'),
        children: [
            {

                path: 'index',
                name: 'index',
                meta:{mateAdmin:10},
                component: ()    => import('../page/home/layout.vue'),
            },
            {
                path: 'admin',
                name: 'admin',
                meta:{mateAdmin:11},
                component: ()    => import('../page/admin/index.vue'),
                children:[
                    {name:'index',path:'index',meta:{active:1,mateAdmin:11},component: () => import('../page/admin/taskList/index.vue')},
                    {name:'classRoom',path:'classRoom',meta:{active:2,mateAdmin:11},component: () => import('../page/admin/classRoom/index.vue')},
                ]
            },
            {
                path: 'teacher',
                name: 'teacher',
                meta:{mateAdmin:12},
                component: () => import('../page/teacher/index.vue'),
                children:[
                    {name:'index',path:'index',meta:{active:1,mateAdmin:12},component: () => import('../page/teacher/task/index.vue')},
                    {name:'insert',path:'insert',meta:{active:1,mateAdmin:12},component: () => import('../page/teacher/task/insert.vue')},
                    {name:'student',path:'student',meta:{active:2,mateAdmin:12},component: () => import('../page/teacher/student/index.vue')},
                    {name:'lesson',path:'lesson',meta:{active:2,mateAdmin:12},component: () => import('../page/teacher/student/lesson.vue')},
                ]
            },
            {
                path: 'member',
                name: 'member',
                meta:{mateAdmin:13},
                component: () => import('../page/member/index.vue'),
                children:[
                    {name:'index',path:'index',meta:{active:1,mateAdmin:13},component: () => import('../page/member/side/index.vue')},
                    {name:'class',path:'class',meta:{active:2,mateAdmin:13},component: () => import('../page/member/side/class.vue')},
                    {name:'menu',path:'menu',meta:{active:3,mateAdmin:13},component: () => import('../page/member/side/menu.vue')},
                    {name:'right',path:'right',meta:{active:4,mateAdmin:13},component: () => import('../page/member/side/right.vue')}
                ]
            },
            {
                path: 'attend',
                name: 'attend',
                meta:{mateAdmin:14},
                component: () => import('../page/attend/index.vue'),
                children:[
                    {name:'index',path:'index',meta:{active:1,mateAdmin:14},component: () => import('../page/attend/lesson/index.vue')},
                    {name:'student',path:'student',meta:{active:2,mateAdmin:14},component: () => import('../page/attend/student/index.vue')},
                ]
            },
        ]
    },
    {path: '/login', name: 'login', component: () => import('../page/login/index.vue')},

]

var routes=[]
if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
    routes = routesMb
} else {
    routes = routesPc
}



const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes,
    scrollBehavior: () => ({ y: 0 }),//每次都跳转到顶部
})
export default router
